package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.HotelDictionary;
import cn.wolfcode.trip.base.mapper.HotelDictionaryMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IHotelDictionaryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HotelDictionaryServiceImpl implements IHotelDictionaryService {
    @Autowired
    private HotelDictionaryMapper hotelDictionaryMapper;

    @Override
    public PageInfo<HotelDictionary> query(QueryObject qo) {

        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<HotelDictionary> list = hotelDictionaryMapper.queryForList(qo);


        return new PageInfo<>(list);

    }




    @Override
    public void saveOrUpdate(HotelDictionary hotelDictionary) {
        if (hotelDictionary.getId()!=null) {
            hotelDictionaryMapper.updateByPrimaryKey(hotelDictionary);
        }else{
            hotelDictionaryMapper.insert(hotelDictionary);
        }

    }

    @Override
    public void delete(Long id) {
        hotelDictionaryMapper.deleteByPrimaryKey(id);

    }

    @Override
    public HotelDictionary selectByPrimaryKey(Long id) {
        return hotelDictionaryMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<HotelDictionary> selectAll() {
        return hotelDictionaryMapper.selectAll();
    }
}
